#include "ResizeCmd.h"
#include "../model/UMLBox.h"

ResizeCmd::ResizeCmd(UMLBox* target)
:	_executed(false),
	_target(target),
	_size(target->rect().size())
	// default is fine for _oldSize
{
}

QSize ResizeCmd::size() const
{
	return _size;
}

void ResizeCmd::setSize(const QSize& size)
{
	_size = size;
}

void ResizeCmd::execute()
{
	if (!_executed)
	{
		_oldSize = _target->rect().size();
	}

	_target->setSize(_size);

	_executed = true;
}

void ResizeCmd::unexecute()
{
	if (!_executed)
		return;

	_target->setSize(_oldSize);

	_executed = false;
}

const char* ResizeCmd::name() const
{
	return "ResizeCmd";
}

